<template>
  <div class="hljs">
    <el-form :model="dataFrom"
             size="small"
             ref="dataForm"
             :rules="dataFormRules"
             label-width="160px">
      <div class="system">视讯平台配置</div>
      <el-form-item label="模板审核回调URL" prop="notifyUrl">
        <el-input v-model="dataFrom.notifyUrl" placeholder="请输入模板审核回调URL"></el-input>
      </el-form-item>
      <el-form-item label="短信发送回调" prop="sendMsgNotifyUrl">
        <el-input v-model="dataFrom.sendMsgNotifyUrl" placeholder="请输入短信发送回调"></el-input>
      </el-form-item>
      <el-form-item label="模板创建接口" prop="addModeApi">
        <el-input v-model="dataFrom.addModeApi" placeholder="请输入模板创建接口"></el-input>
      </el-form-item>
      <el-form-item label="模板更新接口" prop="updModeApi">
        <el-input v-model="dataFrom.updModeApi" placeholder="请输入模板更新接口"></el-input>
      </el-form-item>
      <el-form-item label="短信发送接口" prop="sendVsmsApi">
        <el-input v-model="dataFrom.sendVsmsApi" placeholder="请输入短信发送接口"></el-input>
      </el-form-item>
      <el-form-item label="彩信签名" prop="sign">
        <el-input v-model="dataFrom.sign" placeholder="请输入彩信签名"></el-input>
      </el-form-item>
      <el-form-item label="服务号码" prop="vsmsCode">
        <el-input v-model="dataFrom.vsmsCode" placeholder="请输入服务号码"></el-input>
      </el-form-item>
      <el-form-item label="模板名称" prop="modeName">
        <el-input v-model="dataFrom.modeName" placeholder="请输入模板名称"></el-input>
      </el-form-item>
      <el-form-item label="用户名" prop="appKey">
        <el-input v-model="dataFrom.appKey" placeholder="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="secret">
        <el-input v-model="dataFrom.secret" type="password" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item label="日报确认同意标识" prop="agree">
        <el-input v-model="dataFrom.agree" placeholder="请输日报确认同意标识"></el-input>
      </el-form-item>
      <el-form-item label="日报不同意标识" prop="nonAgree">
        <el-input v-model="dataFrom.nonAgree" placeholder="请输入日报不同意标识"></el-input>
      </el-form-item>
      <el-form-item label="模板审核通知模板ID" prop="modeId">
        <el-input v-model="dataFrom.modeId" placeholder="请输入模板审核通知模板ID"></el-input>
      </el-form-item>
    </el-form>
    <div style="text-align: left">
      <el-button
        :loading="dialogLoading"
        @click="submitForm"
        type="primary"
        size="small">
        保存
      </el-button>
    </div>
  </div>
</template>

<script>
  import {progressConfig} from '@/api/dailyweekly/workflow'
  export default {
    props: {
      dataFrom: {
        type: Object
      },
    },
    data() {
      return {
        dialogLoading: false,
        // dataFrom: {
        //   notifyUrl: '',
        //   addModeApi: '',
        //   updModeApi: '',
        //   sendVsmsApi: '',
        //   sign: '',
        //   vsmsCode: '',
        //   modeName: '',
        //   appKey: '',
        //   secret: '',
        //   agree: '',
        //   nonAgree: ''
        // },
        dataFormRules: {
          notifyUrl: [
            { required: true, message: '请输入模板审核回调URL', trigger: 'blur' }
          ],
          addModeApi: [
            { required: true, message: '请输入模板创建接口', trigger: 'blur' }
          ],
          updModeApi: [
            { required: true, message: '请输入更新创建接口', trigger: 'blur' }
          ],
          sendVsmsApi: [
            { required: true, message: '请输入短信发送接口', trigger: 'blur' }
          ],
          sign: [
            { required: true, message: '请输入彩信签名', trigger: 'blur' }
          ],
          vsmsCode: [
            { required: true, message: '请输入服务号码', trigger: 'blur' }
          ],
          modeName: [
            { required: true, message: '请输入模板名称', trigger: 'blur' }
          ],
          appKey: [
            { required: true, message: '请输入用户名', trigger: 'blur' }
          ],
          secret: [
            { required: true, message: '请输入密码', trigger: 'blur' }
          ],
          agree: [
            { required: true, message: '请输入日报确认同意标识', trigger: 'blur' }
          ],
          nonAgree: [
            { required: true, message: '请输入日报不同意标识', trigger: 'blur' }
          ],
          sendMsgNotifyUrl: [
            { required: true, message: '请输入发送短信回调', trigger: 'blur' }
          ],
          modeId: [
            { required: true, message: '请输入模板审核通知模板ID', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      submitForm () {
        this.$refs['dataForm'].validate(valid => {
          if (valid) {
            this.AddConfigDaily()
          }
        })
      },
      async AddConfigDaily () {
        const data = await progressConfig(this.dataFrom, 'post')
        if (data) {
          if (data.code === 200) {
            this.queryConfigDatily()
          }
        }
      }
    }
  }
</script>

<style scoped>
  .hljs{
    line-height: 1.8;
    font-family: Menlo,Monaco,Consolas,Courier,monospace;
    font-size: 12px;
    padding: 18px 24px;
    background-color: #fafafa;
    border: 1px solid #eaeefb;
    margin-bottom: 25px;
    border-radius: 4px;
    -webkit-font-smoothing: auto;
  }
  .system{
    font-size: 20px;
    text-align: left;
    line-height: 40px;
    margin-top: -10px;
    font-weight: bold;
  }
</style>
